<template>
	<div>
		<List style="padding: 10px 0 0 10px;" v-for="item in list">
			<ListItem>
				<ListItemMeta :avatar="item.avatar_url" :title="item.op_type+'了' + item.obj_type  + item.name" :description="'所在资料库：' + item.repo_name " />
				操作人员：{{item.author_name}}</br>
				操作时间：{{item.time}}</br>
				路径：{{item.path}}</br>
			</ListItem>
		</List>
	</div>
</template>

<script>
	import axios from "axios"
	export default {
		data() {
			return {
				list: []
			}
		},
		mounted() {
			// 获取文件活动列表
			var Token = window.localStorage.getItem("Token")
			axios({
				url: "https://cloud.seafile.com/api/v2.1/activities/?page=1&avatar_size=72",
				method: "get",
				headers: {
					Authorization: "Token " + Token
				}
			}).then((res) => {
				console.log(res.data.events)

				this.list = res.data.events

				for (var i = 0; i < this.list.length; i++) {
					//定义空字符串size
					var op_type = "";
					//获取数组内的size并赋值变量
					var op_type = this.list[i].op_type;
					//判断文件大小
					if (op_type == "delete") {
						op_type = "删除";
					} else if (op_type == "create") {
						op_type = "创建";
					}


					//定义空字符串size
					var obj_type = "";
					//获取数组内的size并赋值变量
					var obj_type = this.list[i].obj_type;
					//判断文件大小
					if (obj_type == "file") {
						obj_type = "文件";
					} else if (obj_type == "repo") {
						obj_type = "资料库";
					} else if (obj_type == "dir") {
						obj_type = "文件夹";
					}


					// 将数据重新放入到obj数组里面
					var obj = this.list[i]; //或者 var obj=new Object();
					var key = "op_type";
					obj[key] = op_type;
					
					var key1 = "obj_type";
					obj[key1] = obj_type;

				}




			})
		}
	}
</script>

<style>
</style>
